#ifndef RELATIONBUTTON_H
#define RELATIONBUTTON_H

#include <QDebug>

#include <QGraphicsItemGroup>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
#include <QDrag>
#include <QMimeData>
#include <limits>

#include "uml/relations/draggedrelation.h"
#include "uml/relations/decorators/decoratorgraphicsitem.h"

class UmlRelationalItem;

class RelationButton :public QObject, public QGraphicsItemGroup
{
    Q_OBJECT
public:
    RelationButton(QGraphicsObject *parent = 0);
    ~RelationButton();

    void setRelationalItem(UmlRelationalItem *relationalItem);

    virtual void updateBoundingBox();
    virtual QRectF boundingRect() const;

    void startRelationDrag();

    qreal width();
    qreal height();
    void setTopLeft(QPointF pos);

    void setIsHovered(bool isHovered);

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

    QVariant itemChange(GraphicsItemChange change, const QVariant &value);

protected:
    UmlRelationalItem *_relationalItem;
    QRectF _boundingBox;
    QPen _pen;
    QBrush _brush;
    QBrush _hoverBrush;

    bool _ishovered;
    bool _isPressed;

    virtual DraggedRelation* draggedRelation() = 0;

    DecoratorGraphicsItem _decorator;

signals:
    void startRelationDrag(DraggedRelation *draggedRelation);

};

#endif // RELATIONBUTTON_H
